package team.pwy.mapper;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import team.pwy.pojo.entity.Phone;
import team.pwy.pojo.entity.User;

import java.util.List;

@Repository
public interface UserMapper {

    @Select("select * from pwy.pwy_user where account = #{account} and password = #{password}")
    User login(@Param("account") String nickname, @Param("password") String password);

    @Select("select * from pwy.pwy_user where account = #{value};")
    User findByAccount(String account);

//    @Insert("insert into pwy_user(account,password) values (#{account},md5(#{password}))")
//    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
//    @SelectKey(statement = "select last_insert_id()",keyColumn = "id",keyProperty = "id",before = false,resultType = Integer.class)
    Integer register(User user);

    @Select("select * from pwy.pwy_user where id = #{value};")
    User findByUserId(Integer userId);

    Integer updateMessage(User user);
    @Select("select * from pwy.pwy_user where phone = #{value}")
    User findByPhone(String phone);

    //根据电话号添加默认用户
    @Insert("insert into pwy.pwy_user (account,password,phone) values (#{account},#{password},#{phone})")
    Integer addUser(@Param("account") String account,@Param("password") String password,@Param("phone") String phone);

}
